home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 May: Tool Chest / Apple_Developer_Group_CD_Series_May_1995_Tool_Chest.iso / Sample Code / RAMDisk 1.1 / RamDisk.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-13  |  5.5 KB  |  226 lines  |  [TEXT/MPS ]

  1. /*
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    StandardFileIcons: A sample control panel changing behavior of StandardFile.
  5. **
  6. **    by Gordon Sheridan and Jim Luther
  7. **  modified by Brian Bechtel
  8. **
  9. **    File:        RamDisk.h
  10. **
  11. **    Copyright © 1992-1994 Apple Computer, Inc.
  12. **    All rights reserved.
  13. **
  14. **    You may incorporate this sample code into your applications without
  15. **    restriction, though the sample code has been provided "AS IS" and the
  16. **    responsibility for its operation is 100% yours.  However, what you are
  17. **    not permitted to do is to redistribute the source as "DTS Sample Code"
  18. **    after having made changes. If you're going to re-distribute the source,
  19. **    we require that you make it clear in the source that the code was
  20. **    descended from Apple Sample Code, but that you've made changes.
  21. **
  22. ** Change History (most recent first):
  23. ** 
  24. **      <3>    10/14/93    JML        Added Panic debug macros and changed preprocessor constants
  25. **                                 to enums.
  26. **      <2>     6/13/93    gs        Move dCtlFlag bits from RamDRVR.c and cleanup header.
  27. **      <1>     8/24/92    gs        first checked in
  28. **/
  29.  
  30. #ifndef __RAMDISK__
  31. #define __RAMDISK__
  32.  
  33. #ifndef rez
  34.  
  35. #include <Types.h>
  36. #include <Errors.h>
  37. #include <LowMem.h>
  38. #include <Traps.h>
  39. #include <GestaltEqu.h>
  40. #include <Memory.h>
  41. #include <Quickdraw.h>
  42. #include <DiskInit.h>
  43. #include <SegLoad.h>
  44. #include <OSUtils.h>
  45. #include <Script.h>
  46. #include <ToolUtils.h>
  47. #include <Events.h>
  48. #include <Controls.h>
  49. #include <TextEdit.h>
  50. #include <Desk.h>
  51. #include <Windows.h>
  52. #include <Dialogs.h>
  53. #include <Devices.h>
  54. #include <Disks.h>
  55. #include <Files.h>
  56. #include <Resources.h>
  57. #include <Packages.h>
  58.  
  59. #ifdef __MWERKS__
  60. #include <A4Stuff.h>
  61. #endif
  62. #ifdef THINK_C
  63. #include <SetupA4.h>
  64. #endif
  65.  
  66.  
  67. #if __DebugVersion
  68.     extern            void    Breakpoint    (void)                = 0xA9FF;
  69.     extern    pascal    void    Panic        (unsigned char *    Message)    = 0xABFF;
  70.     #define PanicIf(condition, message)    if (condition) Panic(message)
  71. #else
  72.     #define BreakPoint()
  73.     #define Panic(param)
  74.     #define PanicIf(param1,param2)
  75. #endif
  76.  
  77.  
  78. #define        kDriverName        "\p.RamDRVR"
  79. #define        kDRVRType        'DRVR'
  80.  
  81.  
  82. /*
  83. **    dCtlFlags bits
  84. */
  85.  
  86. #define        dNeedLock        0x4000
  87. #define        dNeedTime        0x2000
  88. #define        dNeedGoodBye    0x1000
  89. #define        dStatEnable        0x0800
  90. #define        dCtlEnable        0x0400
  91. #define        dWritEnable        0x0200
  92. #define        dReadEnable        0x0100
  93. #define        drvrActive        0x0080
  94. #define        dRAMBased        0x0040
  95. #define        dOpened            0x0020
  96.  
  97.  
  98. /*
  99. **    Low byte of trap word for _Read and _Write
  100. */
  101.  
  102. #define        aRdCmd            2
  103. #define        aWrCmd            3
  104.  
  105.  
  106. /*
  107. **    Standard disk driver csCodes
  108. */
  109.  
  110. /* Control codes */
  111. #define        killIOCC        1        /* kill I/O */
  112. #define        verifyDiskCC    5        /* verify disk */
  113. #define        formatDiskCC    6        /* format disk */
  114. #define        ejectDiskCC        7        /* eject disk (ejectable media only) */
  115. #define        setTagBufferCC    8        /* set tag buffer (.SONY) */
  116. #define        trackCacheCC    9,        /* control track cache (.SONY) */
  117. #define        physicalIconCC    21        /* return physical location icon and where string */
  118. #define        mediaIconCC        22        /* return media icon */
  119. #define        driveInfoCC        23        /* return drive info */
  120. #define        trackDumpCC        18244    /* diagnostic raw track dump (.SONY) */
  121.     
  122. /* Status codes */
  123. #define        returnFormatList 6        /* return format list (.SONY) */
  124. #define        driveStatusSC    8        /* drive status */
  125.  
  126.  
  127. /*
  128. **    Our driver specific csCodes
  129. */
  130.  
  131. /* Control codes */
  132. #define        setGlobalsCC    128        /* copy data pointed to by csParam to driver globals */
  133.     
  134. /* Status codes */
  135. #define        getGlobalsSC    128        /* return pointer to driver globals */
  136.  
  137.  
  138. /*
  139. **    Unit table constants
  140. */
  141.  
  142. #define        kMaxUTEntries    128        /* maximum size of unit table */
  143. #define        kMinUnitNum        48        /* the lowest unit number we can use */
  144.  
  145.  
  146. /* Driver globals structure */
  147. struct DrvrGlobals
  148. {
  149.     Ptr            ramDisk;
  150.     long        ramSize;
  151.     short        driveNumber;
  152.     Str255        volumeName;
  153.     long        physicalIcon[kLargeIconSize/4];    /* IMPORTANT: icon and whereString must be  */
  154.     Str255        locationStr;                /* end-to-end in memory! */
  155.     long        mediaIcon[kLargeIconSize/4];
  156. };
  157. typedef struct DrvrGlobals DrvrGlobals;
  158. typedef DrvrGlobals *DrvrGlobalsPtr, **DrvrGlobalsHandle;
  159.  
  160.  
  161. /* ConfigRec resource structure */
  162. struct ConfigRec
  163. {
  164.     short        install;    /* boolean true/false */
  165.     long        size;
  166.     Str255        volumeName;
  167. };
  168. typedef struct ConfigRec ConfigRec;
  169. typedef ConfigRec *ConfigRecPtr, **ConfigRecHandle;
  170.  
  171.  
  172. /* A DrvQEl with flags */
  173. struct MyDrvQEl
  174. {
  175.     long            flags;
  176.     QElemPtr        qLink;
  177.     short            qType;
  178.     short            dQDrive;
  179.     short            dQRefNum;
  180.     short            dQFSID;
  181.     unsigned short    dQDrvSz;
  182.     unsigned short    dQDrvSz2;
  183. };
  184. typedef struct MyDrvQEl MyDrvQEl;
  185. typedef MyDrvQEl *MyDrvQElPtr;
  186.  
  187.  
  188. /* FormatListRec as returned Return Format List status call (csCode = 6). */
  189. struct FormatListRec
  190. {
  191.     unsigned long                volSize;            /* disk capacity in SECTORs */
  192.     SignedByte                    formatFlags;        /* flags */
  193.     SignedByte                    sectorsPerTrack;    /* sectors per track side */
  194.     unsigned short                tracks;                /* number of tracks */
  195. };
  196. typedef struct FormatListRec FormatListRec;
  197. typedef FormatListRec *FormatListRecPtr;
  198.  
  199.  
  200. #endif    /* end of non-rez */
  201.  
  202.  
  203. /*
  204. **    Our resource IDs
  205. */
  206.  
  207. #define        rCDevSignature        0        /* RamDisk's registered signature ('RDsk') resource ID */
  208. #define        rCdev                -4064    /* Required cdev resource ID */
  209.  
  210. #define        rStringList            -4033
  211. #define        rLocationStr        1        /* The "where" string used in the Get Info dialog */
  212. #define        rDefaultNameStr        2        /* The initial default volume name */
  213.  
  214. /* icon family resource IDs */
  215. #define        rLoadOKIcon            -4064    /* same as cdev icon */
  216. #define        rLoadBadIcon        -4033
  217. #define        rPhysicalIcon        -4034
  218. #define        rMediaIcon            -4035
  219.  
  220. /* cdev dialog item resource IDs */
  221. #define        rCDevCheckbox        -4033
  222. #define        rCDevLogoPICT        -4033
  223. #define        rCDevSizeBarPICT    -4034
  224.  
  225. #endif __RAMDISK__
  226.